home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 9
/
The PC-SIG Library on CD ROM - Ninth Edition.iso
/
301_400
/
DISK0324
/
DISK0324.ZIP
/
PLOTFUNC.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1984-06-12
|
3KB
|
129 lines
program func;
{ 3d hidden line plot routine by Jim Reider, Atlanta, Ga. }
{ This program plots two functions on the hires screen. The }
{ plotting functions have hidden line features. }
{ The program uses two external procedures. You must have }
{ POINT.INV and LINE.INV on the default disk drive in order }
{ to compile this program. }
{ Translated into TurboPascal by Jeff Firestone. June, 1984 }
type
PassNum = (First, Second);
var
x1,y1,bs,b1,b2,a,k,g,r,x2,y2,r2,m1,q1,q2,gr,k1,k3,k4 : real;
v1,s1,hm,h,v,rc,x,y,z,rr : real;
NewX, NewY, OldX, OldY, q, z1, k2 : integer;
hh : array [0..150] of integer;
f, OkTest : boolean;
Pass : PassNum;
procedure dot (a,b,c :integer); external 'point.inv';
procedure line(a,b,c,d,e:integer); external 'line.inv';
procedure Init;
begin
FillChar(hh, sizeof(hh), 0);
X1:= 0; Y1:= 0; OldX:= 0; OldY:= 0;
BS:= 0.01; k:=0; g:=0; r:=0; a:=0;
B1:= 1 - ((2 * LN(1)) / (LN(1) - LN(BS)));
B2:= 2 / (LN(1) - LN(BS));
write('WHICH FUNCTION (0 OR 1) '); read(A); writeln;
write('RANGE (Default:= 2) '); read(k); IF K = 0 THEN K:= 2; writeln;
write('GRID (Default:= 16) '); read(g); IF G = 0 THEN G:= 16; writeln;
write('RESOL (Default:= 2) '); read(r); IF R = 0 THEN R:= 2; writeln;
X2:= K * PI;
Y2:= K * PI;
R2:= 2*R; M1:= G*R2; Q1:= M1-R; Q2:= M1+R; GR:= G*R;
K1:= 300 / M1;
K2:= 96;
K3:= 96 / (SQRT(3) * M1);
K4:= 48 / SQRT(3);
Hires; HiresColor(7);
end;
begin
Init;
Pass:= First;
v1:= -q1;
repeat
S1:= -(V1 / abs(v1));
HM:= Q2 - ABS(V1);
H:= -HM;
V:= V1 + (R * S1);
F:= False;
rc:= r;
repeat
if (rc <= 0) and (Pass = Second) then
begin
S1:= -S1;
RC:= R;
end;
Pass:= Second;
X:= X1 + (V + H) * (X2 / M1);
Y:= Y1 + (V - H) * (Y2 / M1);
if (a = 0) then
begin
Z:= 1;
IF (X <> 0) THEN Z:= SIN(X) / X;
IF (Y <> 0) THEN Z:= Z * SIN(Y) / Y;
Z:= ABS(Z);
end;
if (a <> 0) then
begin
RR:= SQRT((X * X) + (Y * Y));
IF (RR = 0) THEN Z:= 1;
IF (RR > X2) THEN Z:= -1;
if not((rr = 0) or (rr > x2)) then Z:= ABS(SIN(RR) / RR);
end;
if (a = 0) or not((rr = 0) or (rr > x2)) then
begin
IF (Z < BS) THEN
Z:= -1
ELSE
Z:= B1 + (B2 * LN(Z))
end;
Z1:= K2 + round((V * K3) + (Z * K4));
Q:= trunc(GR + (H / 2));
OkTest:= True;
IF (Z1 >= HH[Q]) THEN
BEGIN
OkTest:= False;
HH[Q]:= Z1;
Z1:= 200 - Z1;
IF (F = true) THEN
begin
NewX:= 320+round(h * k1);
line (OldX, OldY, NewX, Z1, 1);
OldX:= NewX; OldY:= Z1;
end;
if (f = false) then
begin
NewX:= 320+round(H * K1);
dot (NewX, Z1, 1);
OldX:= NewX; OldY:= Z1;
F:= true;
end;
END;
if OkTest then F:= false;
if (h <> hm) then
begin
V:= V - (2 * S1);
H:= H + 2;
RC:= RC - 1;
end;
until (h = hm);
v1:= v1 + r2;
until (v1 >= q1);
end.